package top.tupobi.zing;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.StringUtils;

import java.io.File;

public class InfoRecord {
    private static final String USERNAME = "USERNAME";
    private static final String CHAT_BACKGROUND_IMAGE_PATH = "IMAGE_PATH";
    private static final String NICKNAME = "NICKNAME";
    private static final String USER_ID = "USER_ID";
    private static final String AVATAR_URL = "AVATAR_URL";
    private static final String HAS_NEW_FRIEND = "HAS_NEW_FRIEND";
    private static final String CURRENT_CHAT_FRIEND_JSON = "CURRENT_CHAT_FRIEND_JSON";
    private static final String ATY_CHAT_STATUS = "ATY_CHAT_STATUS";

    public static void setAtyChatStatus(int status) {
        SPUtils.getInstance().put(ATY_CHAT_STATUS, status);
    }

    public static int getAtyChatStatus() {
        return SPUtils.getInstance().getInt(ATY_CHAT_STATUS);
    }

    public static void setUsername(String username) {
        SPUtils.getInstance().put(USERNAME, username);
    }

    public static String getUsername() {
        return SPUtils.getInstance().getString(USERNAME);
    }

    public static boolean isLogin() {
        return !StringUtils.isEmpty(getUserId()) && !StringUtils.isEmpty(getUsername());
    }

    public static void setChatBackgroundImagePath(String imagePath) {
        File file = new File(imagePath);
        if (file.exists() && file.canRead()) {
            SPUtils.getInstance().put(CHAT_BACKGROUND_IMAGE_PATH, imagePath);
        }
    }

    public static String getChatBackgroundImagePath() {
        return SPUtils.getInstance().getString(CHAT_BACKGROUND_IMAGE_PATH);
    }

    public static void setNickname(String nickname) {
        SPUtils.getInstance().put(NICKNAME, nickname);
    }

    public static String getNickname() {
        return SPUtils.getInstance().getString(NICKNAME);
    }

    public static void setUserId(String userId) {
        SPUtils.getInstance().put(USER_ID, userId);
    }

    public static String getUserId() {
        return SPUtils.getInstance().getString(USER_ID);
    }

    public static void setAvatarUrl(String avatarUrl) {
        SPUtils.getInstance().put(AVATAR_URL, avatarUrl);
    }

    public static String getAvatarUrl() {
        return SPUtils.getInstance().getString(AVATAR_URL);
    }

    public static void setHasNewFriend(boolean hasNewFriend) {
        SPUtils.getInstance().put(HAS_NEW_FRIEND, hasNewFriend);
    }

    public static boolean getHasNewFriend() {
        return SPUtils.getInstance().getBoolean(HAS_NEW_FRIEND);
    }

    public static String getCurrentChatFriendJson() {
        return SPUtils.getInstance().getString(CURRENT_CHAT_FRIEND_JSON);
    }

    public static void setCurrentChatFriendJson(String friendJson) {
        SPUtils.getInstance().put(CURRENT_CHAT_FRIEND_JSON, friendJson);
    }
}
